# -*- coding: utf-8 -*-
# ===========================================
# @Time    : 2021/9/14 16:57 
# @Author  : shutao
# @FileName: facenet_base.py
# @remark  : 
# 
# @Software: PyCharm
# Github 　： https://github.com/NameLacker
# ===========================================

import paddle
import os

from modules.exp.base_exp import BaseExp
from modules.utils import LRScheduler


class Exp(BaseExp):
    """The experiment of face matching."""

    def __init__(self):
        super(Exp, self).__init__()

        self.img_size = (224, 224)
        self.max_epoch = 10
        self.base_lr = 0.05
        pass

    def get_model(self):
        from ..models.backbones import FaceNet

        net = FaceNet()
        paddle.summary(net, (1, 3, 224, 224))
        return net

    def get_data_loader(self, batch_size: int):
        from ..data.datasets import FaceDataset

        dataset = FaceDataset(root_path="E:\\work\\Dataset\\lfw", img_size=self.img_size)
        td_loader = paddle.io.DataLoader(dataset, num_workers=0, batch_size=batch_size, drop_last=True)
        return td_loader, dataset.num_samples

    def get_loss_function(self, **kwargs) -> paddle.Tensor:
        from ..models.losses import TripletLoss

        triplet_loss = TripletLoss()

        return triplet_loss

    def get_optimizer(self, lr: LRScheduler, parameters: paddle.nn.Layer.parameters):
        pass

    def get_lr_scheduler(self, lr: float, iters_per_epoch: int, **kwargs):
        # todo: 写到这儿辣
        pass

    def get_training_subject(self, data, loss_func):
        pass

    def get_evaluator(self, batch_size: int):
        pass

    def eval(self, model, evaluator, weights):
        pass
